package coreutil

import "encoding/json"

type jsonUtil struct {
}

func (p *jsonUtil) Marshal(v interface{}) (string, error) {
	buff, err := json.Marshal(v)
	if err != nil {
		return "", err
	}
	return string(buff), nil
}

func (p *jsonUtil) Unmarshal(str string, v interface{}) error {
	buff := []byte(str)
	err := json.Unmarshal(buff, v)
	if err != nil {
		return err
	}
	return nil
}

var (
	Json = &jsonUtil{}
)
